<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.netcombine.freewill.constants.*, com.netcombine.freewill.lib.Paging,com.netcombine.freewill.vo.PagingVo " %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
Paging paging = (Paging)request.getAttribute("paging");

PagingVo vo = (PagingVo)request.getAttribute("pagingVo"); 

int total_cnt = paging.getTotalCnt();
String searchName = "";
String searchWord = "";
String cmdepth_idx = "";

if(vo != null){
	searchName = vo.getSearchName() == null ? "" : vo.getSearchName();
	searchWord = vo.getSearchWord() == null ? "" : vo.getSearchWord();
}

%>


<html>
<head>

<title><%=PageInfo.TITLE%> - 커뮤니티</title>
<tiles:insertDefinition name="_head" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {	
	 $( "#startday" ).datepicker({
		 showOn: "button",
		 buttonImage: "<%= PageInfo.IMG_PATH %>/icon_calendar.png",
		 buttonImageOnly: true,
		 dateFormat:"yy-mm-dd",
		 defaultDate: "+1w",
		 changeMonth: true,
		 numberOfMonths: 1,
		 onClose: function( selectedDate ) {
			 $( "#lastday" ).datepicker( "option", "minDate", selectedDate );
		}
	});
		$( "#lastday" ).datepicker({
		showOn: "button",
		buttonImage: "<%= PageInfo.IMG_PATH %>/icon_calendar.png",
		buttonImageOnly: true,
		dateFormat:"yy-mm-dd",
		defaultDate: "+1w",
		changeMonth: true,
		numberOfMonths: 1,
		onClose: function( selectedDate ) {
		$( "#startday" ).datepicker( "option", "maxDate", selectedDate );
	}
  });
});
function searchFrm(){
	var frm = document.searchForm;
	
	frm.action = "<%= request.getContextPath()%>/community/list.do";
	frm.submit();
}
</script>
	
</head>

<body>

<div class="wrap">
	<tiles:insertDefinition name="_header" />

<div class="container">
	<div>
	<tiles:insertDefinition name="_menu" />

<!-- Content -->
<div class="content">
	
	<!-- locatioin -->
<div class="location">
	<h1>커뮤니티 관리</h1>
	<ul>
		<li class="home"><a href="#none"><span>home</span></a> &gt;</li>
		<li><strong>커뮤니티 관리</strong></li>
	</ul>
</div>
<!-- locatioin // -->
<form name="searchForm" method="POST">
<!-- member_search -->
<div class="member_search">
	<table summary="커뮤니티관리, 검색설정, 검색기간">
		<caption>커뮤니티관리</caption>
		<colgroup>
			<col style="width:15%">
			<col style="width:*;">
			<col style="width:15%">
</colgroup>
<tbody>
	<tr>
		<th>개설일</th>
		<td>
		
				<input type="text" id="startday" name="startday" title="검색 시작날짜" class="i_text inw8" /> ~ 
				<input type="text" id="lastday" name="lastday" title="검색 마지막날짜" class="i_text inw8" />
			</td>
			<td rowspan="6" class="txtC"><span class="btn_member bgnone"><a href="javascript: searchFrm();">검색</a></span></td>
		</tr>
		<tr>
			<th>
				<select name="searchName">
					<option value = "커뮤니티명" <%if(searchName.equals("커뮤니티명")){out.print("selected='selected'");} %>>커뮤니티명</option>
					<option value = "매니저" <%if(searchName.equals("매니저")){out.print("selected='selected'");} %>>매니저</option>
				</select>
			</th>
			<td><input type="text" name="searchWord" title="검색" class="i_text inw3" value="<%=searchWord%>"></td>
		</tr>
		<tr>
			<th>공개여부</th>
			<td>
				<label for=""><input type="checkbox"/>공개</label>
				<label for=""><input type="checkbox"/>비공개</label>
			</td>
		</tr>
		<tr>
			<th>가입자</th>
			<td><input type="text" title="검색" class="i_text inw8"> 명 ~ <input type="text" title="검색" class="i_text inw8"> 명</td>
		</tr>
		<tr>
			<th>공유</th>
			<td><input type="text" title="검색" class="i_text inw8"> 건 ~ <input type="text" title="검색" class="i_text inw8"> 건</td>
		</tr>
		<tr>
			<th>요청</th>
			<td><input type="text" title="검색" class="i_text inw8"> 건 ~ <input type="text" title="검색" class="i_text inw8"> 건</td>
			</tr>
		</tbody>
	</table>
</div>
	<!-- member_search // -->

<!-- tap_box -->
<div class="tap_box">
	<ul>
		<li><a href="<%= request.getContextPath() %>/community/list.do">일반</a></li>
		<li><a href="<%= request.getContextPath() %>/community/list.do">학교</a></li>
		<li><a href="<%= request.getContextPath() %>/community/list.do?cmdepth_type=location">지역</a></li>
		<li><a href="<%= request.getContextPath() %>/community/list.do">공공기관</a></li>
		<li><a href="<%= request.getContextPath() %>/community/list.do">종교단체</a></li>
	</ul>
	<div class="search_detail">
		<p class="txt">총 <span><%=total_cnt %></span> 개</p>
		<p class="right btn_excel"> <a href="#none">EXCEL 저장</a></p>
	</div>
</div>
</form>
<!-- teb_box // -->

<!-- table -->
<form name="writeFrm" method="POST">
<input type="hidden" name="cmdepth_idx">
<div class="tb_list1">
	<table summary="번호, 커뮤니티명, 분류, 공개여부, 개설일, 가입자, 공유, 요청">
		<caption>커뮤니티관리</caption>
		<colgroup>
			<col style="width:8%;">
			<col style="width:*;">
			<col style="width:8%;">
			<col style="width:8%;">
			<col style="width:13%;">
			<col style="width:8%;">
			<col style="width:6%;">
			<col style="width:6%;">
			<col style="width:6%;">
			<col style="width:6%;">
			<col style="width:6%;">
			<col style="width:6%;">
		</colgroup>
		<thead>
		<tr>
			<th scope="col" rowspan="2"><div>No.</div></th>
			<th scope="col" rowspan="2"><div>커뮤니티명</div></th>
			<th scope="col" rowspan="2"><div>분류</div></th>
			<th scope="col" rowspan="2"><div>공개여부</div></th>
			<th scope="col" rowspan="2"><div>개설일</div></th>
			<th scope="col" rowspan="2"><div>가입자</div></th>
			<th scope="col" colspan="3"><div>공유</div></th>
			<th scope="col" colspan="3"><div>요청</div></th>
		</tr>
		<tr>
			<th scope="col"><div>물품</div></th>
			<th scope="col"><div>재능</div></th>
			<th scope="col"><div>장소</div></th>
			<th scope="col"><div>물품</div></th>
			<th scope="col"><div>재능</div></th>
			<th scope="col"><div>장소</div></th>
		</tr>
		</thead>
		<tbody>
		
		<%
			if (total_cnt != 0) {
		%>
				<c:forEach items="${communityList}" var="vo">				
		<tr>
			<td rowspan="2"><c:out value="${vo.cmdepth_idx}" /></td>
			<td rowspan="2"><c:out value="${vo.cmdepth_highlv} ${vo.cmdepth_lowlv}" /></td>
			<td rowspan="2"><c:out value="${vo.cmdepth_type}" /></td>
			<td rowspan="2"><c:out value="${vo.cmdepth_openyn}"/></td>
			<td rowspan="2"><c:out value="${vo.cmdepth_regdate}"/></td>
			<td rowspan="2">${vo.cmjoin_cnt}</td>
			<td colspan="3"><c:out value="${vo.share_cnt}"/></td>
			<td colspan="3"><c:out value="${vo.request_cnt}"/></td>
		</tr>
			<tr>
			<td><c:out value="${vo.share_goods_cnt}"/></td>
			<td><c:out value="${vo.share_talent_cnt}"/></td>
			<td><c:out value="${vo.share_place_cnt}"/></td>
			<td><c:out value="${vo.request_goods_cnt}"/></td>
			<td><c:out value="${vo.request_talent_cnt}"/></td>
			<td><c:out value="${vo.request_place_cnt}"/></td>
		</tr>
		</c:forEach>
		
		<%
		} 
		%>
		
		</tbody>
	</table>
</div>
</form>
<!-- table // -->

<!-- paging -->
${paging.getPagingHtml()}
<!-- paging // -->
		
	</div>
	</div>
</div>
</div>	
<form name="pageForm" method="POST">
<input type="hidden" name="page" value="${pagingVo.page}"/>
<input type="hidden" name="searchName" value="${pagingVo.searchName}"/> 
<input type="hidden" name="searchWord" value="${pagingVo.searchWord}" />
</form>
</body>
</html>